package com.mingserve.common.mqtt.listener;

import lombok.extern.slf4j.Slf4j;
import org.eclipse.paho.client.mqttv3.IMqttMessageListener;
import org.eclipse.paho.client.mqttv3.MqttMessage;
import org.springframework.stereotype.Component;

/**
 * MQTT消息监听
 *
 * @author lvwshuai
 * @date 2022-12-09
 */
@Slf4j
@Component
public class MessageListener implements IMqttMessageListener
{
    /**
     * 处理消息
     *
     * @param topic       主题
     * @param mqttMessage 消息
     */
    @Override
    public void messageArrived(String topic, MqttMessage mqttMessage) throws Exception
    {
        log.info("MQTT: topic [{}] received msg [{}]", topic, new String(mqttMessage.getPayload()));
    }
}